package cn.edu.buaa.cnsatm.traffic_big_data_server.highway.model;

import cn.edu.buaa.cnsatm.traffic_big_data_server.util.DateUtil;
import com.alibaba.fastjson.JSONObject;

import java.text.ParseException;

public class HighwayCongestionModel {
    String road_name;
    String description;
    Double index;
    Double speed;
    String road_id;
    String updatetime;
    String city_name;
    String links;
    double longitude;
    double latitude;
    String geom;
    public HighwayCongestionModel(JSONObject json) throws ParseException {
        this.road_name = json.getString("roadname");
        this.road_id = json.getString("id");
        this.updatetime = DateUtil.getRealTime(json.getString("time"));
        this.index = json.getDouble("index");
        this.speed = json.getDouble("speed");
        this.description = json.getString("semantic");
        this.links = json.getString("links");
        String location = json.getString("location");
        String[] longAndLa = location.split(",");
        this.longitude = Double.parseDouble(longAndLa[0]);
        this.latitude  = Double.parseDouble(longAndLa[1]);
    }

    public HighwayCongestionModel(String road_name, String description, Double index, Double speed, String road_id, String updatetime) {
        this.road_name = road_name;
        this.description = description;
        this.index = index;
        this.speed = speed;
        this.road_id = road_id;
        this.updatetime = updatetime;
    }

    public String getRoad_name() {
        return road_name;
    }

    public String getDescription() {
        return description;
    }

    public Double getIndex() {
        return index;
    }

    public Double getSpeed() {
        return speed;
    }

    public String getRoad_id() {
        return road_id;
    }

    public String getUpdatetime() {
        return updatetime;
    }

    public String getCity_name() {
        return city_name;
    }

    public void setCity_name(String city_name) {
        this.city_name = city_name;
    }

    public String getLinks() {
        return links;
    }

    public double getLongitude() {
        return longitude;
    }

    public double getLatitude() {
        return latitude;
    }

    public String getGeom() {
        return geom;
    }

    public void setGeom(String geom) {
        this.geom = geom;
    }

    @Override
    public String toString() {
        return "HighwayCongestionModel{" +
                "road_name='" + road_name + '\'' +
                ", description='" + description + '\'' +
                ", index=" + index +
                ", speed=" + speed +
                ", road_id='" + road_id + '\'' +
                ", updatetime='" + updatetime + '\'' +
                '}';
    }
}
